﻿<div class="form-horizontal" ms-controller="JHAP"> 
    <div class="form-group">
        <label class="col-xs-2 control-label">计划类型</label>
        <div class="col-xs-4">
            <select class="form-control" ms-duplex="modelData.LeiBie">
                <option ms-repeat-item="ColumnData" ms-attr-val="item.TypeNO" ms-attr-selected="item.TypeNO==modelData.Remark?'selected':''">{{item.TypeNO}}</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">创建人</label>
        <div class="col-xs-4">
            <input type="text" class="form-control szhl_getPeoples szhl_require" signle="Y" ms-duplex="modelData.CRUser" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">计划填写时间</label>
        <div class="col-xs-4">
            <input type="text" class="form-control szhl_form_date  szhl_require" id="inputEmail3" ms-duplex="modelData.RBDate">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">计划内容</label>
        <div class="col-xs-9">
            <textarea id="conContent" class="span2  szhl_UEEDIT form-control szhl_require focus" ms-duplex="modelData.RBContent"></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">完成情况</label>
        <div class="col-xs-9">
            <textarea class="span2  szhl_UEEDIT form-control" rows="6"  ms-duplex="modelData.RBWCQK"></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">附件</label>
        <div class="col-xs-9">
            <input type="text" value="" class="span2  szhl_Upload form-control" ms-duplex="modelData.Files" />
        </div>
    </div>
</div>
<script>

    var tempmodel = avalon.define({
        $id: "JHAP",
        name: "计划安排",

        iswf: false,//是否属于流程表单
        ColumnData: [],
        modelData: (!pmodel.pageType && localStorage.getItem(pmodel.FormCode)) ? $.parseJSON(localStorage.getItem(pmodel.FormCode)) : { "RBDate": ComFunJS.getnowdate("yyyy-mm-dd"), "RBContent": "", "LeiBie": "", "RBWCQK": "", "Files": "", "CRUser": ComFunJS.getCookie("username") },
        inittemp: function (strId) {  
            $.getJSON('/API/FTAPI.ashx?Action=GETCOLUMNLIST', { P1: 12 }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempmodel.ColumnData = resultData.Result; 
                    if (!tempmodel.modelData.LeiBie) {
                        tempmodel.modelData.LeiBie = resultData.Result[0].TypeNO; 
                    }
                }
            })
            if (strId) {
                //编辑加载数据
                $.getJSON('/API/FTAPI.ashx?Action=GETJHAPMODEL', { P1: strId }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempmodel.modelData = resultData.Result;
                        if (tempmodel.modelData.RBDate && tempmodel.modelData.RBDate.length > 10) {
                            tempmodel.modelData.RBDate = tempmodel.modelData.RBDate.substring(0, 10);
                        }

                        setTimeout("ComFunJS.initForm()", 500)
                    }
                })
            } else { 
                ComFunJS.initForm();
            }

        },//初始化
        SaveData: function (btdom, piid) {
            var data = tempmodel.modelData.$model;
            var modelValue = JSON.stringify(data);
            $.post("/API/FTAPI.ashx?ACTION=ADDJHAP", { P1: modelValue }, function (result) {
                var jsonresult = $.parseJSON(result)
                btdom.removeClass("disabled").find("i").hide();
                if ($.trim(jsonresult.ErrorMsg) == "") {
                    ComFunJS.winsuccessnew("操作成功");
                }
            });
        },
    });//@ sourceURL=JHAP.js;
    tempmodel.$watch("modelData.*", function (a, b) {
        if (!tempmodel.modelData.ID) {
            localStorage.setItem(pmodel.FormCode, JSON.stringify(tempmodel.modelData.$model));
        }
    })
</script>